Fix flaky KubernetesInformerCreatorTest on Windows due to shared semaphore race condition#4603
Conversation
…I failure Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@copilot the list should occur before the watch, maybe we should use the countdown latches to ensure that that is true. |
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Done in commit |
KubernetesInformerCreatorTest.informerInjectionfails on Windows because both the pod and configmap watch stubs shared a singlewatchCountsemaphore. On Windows, the pod informer can complete LIST→WATCH, receive the empty{}response, and immediately loop back to fire a second WATCH — all before the configmap informer makes its first WATCH request. Two pod-watch firings then satisfywatchCount.acquire(2), letting the test advance toverify()before the configmap watch ever happens.Changes
CountDownLatch(1)instead of sharedSemaphore: replacedgetCount/watchCount(shared across both informers) with four independent latches —podGetLatch,podWatchLatch,configMapGetLatch,configMapWatchLatch— each wired to its own stubCountDownLatch.countDown()is a no-op once at zero, so repeated firings from one informer cannot accidentally satisfy another informer's gateCountRequestAction: switched fromSemaphore.release()toCountDownLatch.countDown()"prerequisite"parameter;CountRequestAction.doActionrecords anAssertionErrorin a staticAtomicReference<Throwable> orderingViolationif a WATCH fires before the LIST has completed, and the test asserts that field is null at the endOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.